<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>Jw任务管理后台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a>
                    <cite>任务列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form layui-col-space5 demoTable">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="search" id="search"  placeholder="任务名称" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  data-type="reload"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </div>
                </div>
                <div class="layui-card-body ">
                    <table id="demo" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script type="text/html" id="switchTpl">
    <!-- 这里的checked的状态只是演示 -->
    <input type = "checkbox" name = "sex" value = "{{d.id}}" lay-skin = "switch"lay-text = "女|男" lay-filter = "sexDemo" {{ d.id == 10003 ? 'checked': ''}} >
</script>

<script>
    layui.use('table',function() {
            var table = layui.table;

            //执行渲染
            //第一个实例
           table.render({
                elem: '#demo'
                ,method:"post"
                ,height: 600
                ,url: '/v1/log/list' //数据接口
                ,page: true //开启分页
                ,contentType:'application/json'
                ,headers:{
                    "content-type": "application/json;charset=utf-8",
                    "auto":localStorage.getItem('token')
                }
                ,request: {
                    pageName: 'page' //页码的参数名称，默认：page
                    ,limitName: 'limit' //每页数据量的参数名，默认：limit
                }
                ,response: {
                    statusName: 'code' //规定数据状态的字段名称，默认：code
                    ,statusCode: 200 //规定成功的状态码，默认：0
                    ,msgName: 'msg' //规定状态信息的字段名称，默认：msg
                    ,countName: 'count' //规定数据总数的字段名称，默认：count
                    ,dataName: 'data' //规定数据列表的字段名称，默认：data
                }
                ,cols: [[ //表头
                    {field: 'task_name', title: '任务名称'}
                    ,{field: 'add_time', title: '测试时间'}
                    ,{field: 'consuming', title: '耗时'}
                    ,{field: 'result', title: '返回数据'}
                ]]
                ,id: 'testReload'
            });

            var $ = layui.$, active = {
                reload: function(){
                    var search = $('#search');
                    //执行重载
                    table.reload('testReload', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        ,method:"post"
                        ,headers:{
                            "content-type": "application/json;charset=utf-8",
                            "auto":localStorage.getItem('token')
                        }
                        ,where: {
                            search: search.val()
                        }
                    },false);
                }
            };


        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


        });
</script>
</html>